<html>
<head><title>mixer test</title></head>
<body style="margin: 0; cursor: none">
<script src="../tma.js"></script>
<script src="mv_common.js"></script>
<script>
tma.extlibs = [ 'ext/gl-matrix.js', 'ext/mv/MajVj.js' ];
tma.onload = function () {
  MajVj.loadAllPlugins().then(function () {
    var r = 4;
    var width = 1920 / r;
    var height = 1080 / r;
    var vj = new MajVj(width, height, true);
    var mix = { volume: [0.5, 0.5, 0.5] };
    var mixer = vj.create('frame', 'mixer', { channel: 3, controller: mix });
    var ch1 = vj.create('frame', 'sandbox', { id: '18922.0' });
    var ch2 = vj.create('frame', 'sandbox', { id: '18918.0' });
    var ch3 = vj.create('frame', 'sandbox', { id: '18568.0' });  // 18451.0
    vj.run(function (delta) {
      mix.volume[0] = controller.nano2[0];
      mix.volume[1] = controller.nano2[1];
      mix.volume[2] = controller.nano2[2];
      if (mix.volume[0] != 0.0) {
        mixer.bind(0);
        vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
        ch1.draw(delta);
      }
      if (mix.volume[1] != 0.0) {
        mixer.bind(1);
        vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
        ch2.draw(delta);
      }
      if (mix.volume[2] != 0.0) {
        mixer.bind(2);
        vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
        ch3.draw(delta);
      }
      vj.screen().bind();
      mixer.draw(delta);
      vj.screen().flush();
    });
    window.onresize = function () {
      vj.onresize();
    };
  }, function (e) { console.log('plugin load error: ' + e); });
};
</script>
</body>
</html>
